﻿using Invisionware.API.Amazon.Tests.Properties;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;

namespace Invisionware.API.Amazon.Tests
{
	[TestClass()]
	public class ItemOperationsTests
	{
		[TestMethod()]
		public void LookupTest()
		{
			var itemLookup = new AwsItemOperations
			{
				Options = new AwsCommonOptions
				{
					AccessKeyId = Settings.Default.AwsAccessKeyID,
					AccessKeySecret = Settings.Default.AwsKeySecret,
					AssociateTag = Settings.Default.AwsAssociateID
				}
			};

			var resultXml = itemLookup.Lookup(new AwsItemLookupOptions() { ItemId = "B004UJAOLM", IdType = AwsItemIDTypes.ASIN });
			var result = AwsItemResultsParser.ParseItemLookup(itemLookup.Options, resultXml);

			Assert.AreEqual("Wuthering Heights", result.First().ProductName, "Product Name does not match expected value");
		}

		[TestMethod()]
		public void SearchTest()
		{
			var itemLookup = new AwsItemOperations
			{
				Options = new AwsCommonOptions
				{
					AccessKeyId = Settings.Default.AwsAccessKeyID,
					AccessKeySecret = Settings.Default.AwsKeySecret,
					AssociateTag = Settings.Default.AwsAssociateID
				}
			};

			var resultXml = itemLookup.Search(new AwsItemSearchOptions() { Keywords = "milton", SearchIndex = "Books" });
			var result = AwsItemResultsParser.ParseItemLookup(itemLookup.Options, resultXml);

			Assert.AreEqual("Paradise Lost (Dover Thrift Editions)", result.First().ProductName, "Product Name does not match expected value");
		}
	}
}
